package com.bw.zg3.Cate.WX

import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.bw.base.entity.WXEntityResultItem
import com.bw.base.net.ApiServer

@Suppress("UNUSED_EXPRESSION")
class WXSure (val apiServer: ApiServer):PagingSource<Int,WXEntityResultItem>() {
    override fun getRefreshKey(state: PagingState<Int, WXEntityResultItem>): Int? {
        return null
    }

    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, WXEntityResultItem> {
      try {
          val i = params.key ?: 0
          val wx = apiServer.getWX()
          val i1 = if (wx.data.size == 10) i + 1 else null
          return LoadResult.Page(wx.data,null,i1)

      }catch (e:Exception){
          return LoadResult.Error(e)
          e.printStackTrace()
      }
    }
}